package com.njbdqn.activitiComplete.ctrl;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;

import com.njbdqn.activitiComplete.service.UserinfosService;
import com.njbdqn.activitiComplete.vo.Userinfos;

@Controller
@Scope("prototype")
public class UserinfosCtrl {
	@Autowired
	private UserinfosService userSerivce;
	@InitBinder
	public void dataFormat(WebDataBinder wdb){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		sdf.setLenient(true);
		wdb.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
	}
	@RequestMapping("/login.do")
	public String login(HttpSession session,Userinfos user){
		Userinfos us=userSerivce.login(user);
		if(us==null){
			return "index";
		}else{
			if(us.getPower().equals("normal")){
				return "reimb";
			}else if(us.getPower().equals("mamager")){
				return "check";
			}else{
				return "pay";
			}
		}
	} 
	@RequestMapping("/rmb.do")
	public String rmb(String rmb){
		System.out.println("报销单金额："+rmb);
		return "remib";
	}
	@RequestMapping("/check.do")
	public String check(){
		System.out.println("同意报销单");
		return "check";
	}
	@RequestMapping("/pag.do")
	public String pay(){
	System.out.println("付款完成");
	return "pay";
	}
}
